package com.student.demo.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

@Entity
public class Course {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer dId;
	
	private String dNumber;
	
	private String dName;
	
	private String dLeixing;
	
	private Double fFenshu;



	@OneToOne   //private Wifi wifi;  对应husband 的wifi 将主控权交给husband类中的wifi字段
	@JoinColumn(name="bId",unique=true)
	private Teacher teacher;
	
	
	@ManyToMany
	@JoinTable(name="ChengJi_Course",    //建立中间表 搞多对多
	joinColumns= {@JoinColumn(name="dId")},   //主操作的中间表
	inverseJoinColumns= {@JoinColumn(name="fId")}) //副操作的中间表
	private Set<ChengJi> chengJis;
	
	@ManyToOne(cascade=CascadeType.DETACH)     //PERSIST添加数据级联 不需考虑先后顺序
	@JoinColumn(name="eId")     //不能为空  设置外键
	private NianJiZhuanYe nianJiZhuanYe;
	

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public Set<ChengJi> getChengJis() {
		return chengJis;
	}

	public void setChengJis(Set<ChengJi> chengJis) {
		this.chengJis = chengJis;
	}

	public NianJiZhuanYe getNianJiZhuanYe() {
		return nianJiZhuanYe;
	}

	public void setNianJiZhuanYe(NianJiZhuanYe nianJiZhuanYe) {
		this.nianJiZhuanYe = nianJiZhuanYe;
	}

	public Integer getdId() {
		return dId;
	}

	public void setdId(Integer dId) {
		this.dId = dId;
	}

	public String getdNumber() {
		return dNumber;
	}

	public void setdNumber(String dNumber) {
		this.dNumber = dNumber;
	}

	public String getdName() {
		return dName;
	}

	public void setdName(String dName) {
		this.dName = dName;
	}

	public String getdLeixing() {
		return dLeixing;
	}

	public void setdLeixing(String dLeixing) {
		this.dLeixing = dLeixing;
	}

	public Double getfFenshu() {
		return fFenshu;
	}

	public void setfFenshu(Double fFenshu) {
		this.fFenshu = fFenshu;
	}
	
	
}
